package com.woniuxy.article.controller;


import com.woniuxy.article.utils.gaode.GaoDeMapUtil;
import com.woniuxy.article.utils.gaode.Result;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * @Description: 地图控制层
 * @Author: TJ
 * @Date: 2022-01-26 09:36:55
 */
@RestController
@RequestMapping("/goods")
public class GaoDeMapController {
 
    @Resource
    private GaoDeMapUtil gaoDeMapUtil;
 
    public static final Logger log = LoggerFactory.getLogger(GaoDeMapController.class);
 
 

    @PostMapping("/getAddress")
    public Result getAddress(@RequestParam("longitude") String longitude, @RequestParam("latitude") String latitude) {
        try {
            return gaoDeMapUtil.getAddress(longitude, latitude);
        } catch (Exception e) {
            return Result.failed(e.toString());
        }
 
    }
 

    @PostMapping("/getLonLat")
    public Result getLonLat(String address) {
        return gaoDeMapUtil.getLonLat(address);
    }


    @PostMapping("/getDistance")
    public Result getDistance(@RequestParam("startLonLat") String startLonLat,@RequestParam("endLonLat") String endLonLat) {
        return gaoDeMapUtil.getDistance(startLonLat, endLonLat);
    }
}
